﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using LeHouse.Server.Dto;
namespace LeHouse.Server.Dal
{
    /// <summary>
    /// 字典表的DAL操作层
    /// </summary>
    public class System_DictionaryDAL : GenericBaseDAL<System_Dictionary>
    {
        /// <summary>
        ///根据类型分组id获取属于该类型的字典信息
        /// </summary>
        /// <returns></returns>
        public List<System_Dictionary> getDictionarysByDmenuid(int Dmenuid)
        {
            List<System_Dictionary> list = new List<System_Dictionary>();
            
            string sql = @"select Did,DictionaryID,DictionaryName,Dmenuid from t_Dictionary where Dmenuid=@Dmenuid order by (DictionaryID) desc";
            using (var cnn = DbConnection)
            {
                //var CP = cnn.CreateParam("@P_ReportNumber");
                //CP.Value = P_ReportNumber;
                //List<IDbDataParameter> ls = new List<IDbDataParameter>();
                //ls.Add(CP);
                //ls.Add(CP);
                //ls.Add(CP);
                //ls.Add(CP);
                //var list = cnn.SqlList<DataTable>(sql, ls);
                using (var cmd = cnn.CreateCommand())
                {
                    cmd.CommandText = sql;
                    var p = cmd.CreateParameter();
                    p.ParameterName = "@Dmenuid";
                    p.Value = Dmenuid;
                    cmd.Parameters.Add(p);
                    var x = cmd.ExecuteReader();

                    try
                    {
                        while (x.Read())
                        {
                            //Collateral_InquiryRecord d1 = new Collateral_InquiryRecord();
                            //d1.Did = Convert.ToInt32(x["Did"]);
                            //d1.DictionaryID = (string)x["DictionaryID"];
                            //d1.DictionaryName = x["DictionaryName"].ToString();
                            //d1.Dmenuid = (int)x["Dmenuid"];
                            //list.Add(d1);
                        }
                    }
                    finally
                    {
                        x.Close();
                    }
                }
                return list;
            }
        }
    }
}
